<?php

// 4/25/2010: immanuel192 write this action to return bible verse 

if (!defined('EXPONENT')) exit('');

global $db;

if (isset($_REQUEST['book']) && isset($_REQUEST['chapter']))
{
    $translation=0;
	// get translation short name
	$bible=$db->selectObject("bibles","id = " . $translation);
	if ($bible == null) 
	{
		die();
	}
	else
	{
		$short_name = $bible->short_name;
		$book=intval($_REQUEST['book']); $chapter=intval($_REQUEST['chapter']);
		$show_as =0;
		if (isset($_REQUEST['show_as']))
			$show_as=intval($_REQUEST['show_as']);
	
		$data=$db->selectObjects("bible_".$short_name,"book = {$book} AND chapter = {$chapter} ORDER BY verse");
        if (count($data)==0)
        {
            header("Location: /index.php");
            die();
        }
		$html="";
		foreach ($data as $k=>$v)
		{
			$html.="<span id='v{$v->verse}'>{$v->bibletext}</span>";
		}
		
        // for better SEO, get book name :)
        $book_obj=$db->selectObject("bible_info"," bible_id = 0 AND bindex = {$book}");
        $mytitle="Đọc Kinh Thánh - {$book_obj->book_name} {$chapter}";
        _ab_theme_action_register_title($mytitle);
        
        $template = new template('biblemodule',"Default",$loc);
        $template->assign('book_id', $book);
        $template->assign('chapter_id', $chapter);
        $template->assign('bibletext', $html);
        $template->assign('first_need_reload', 0);
        $template->output();
	}
}
else
{
	die();
}
?>
